import { relationalStore } from "@kit.ArkData";

const STORE_CONFIG = {
  name: 'RDB.db',
  securityLevel: relationalStore.SecurityLevel.S1
}

const SQL_CREATE_TABLE_2 = 'CREATE TABLE IF NOT EXISTS BOOKS(ID INTEGER PRIMARY KEY, IMGURL TEXT NOT NULL, TITLE TEXT NOT NULL, AUTHOR TEXT NOT NULL, INTRODUCE TEXT NOT NULL, READNUMBER INTEGER DEFAULT 0, HOT INTEGER DEFAULT 0)';

export default class CreateDatabase{

  static contactDataRdbStore: relationalStore.RdbStore

  static createNow(context){
    relationalStore.getRdbStore(context,STORE_CONFIG,(err,store)=>{
      if(err){
        console.error('失败');
        return;
      }
      console.info('成功')
      store.executeSql(SQL_CREATE_TABLE_2)

      CreateDatabase.contactDataRdbStore = store;
    })
  }
}
